package com.yuanian.springbootProject.service.imp;

import com.yuanian.springbootProject.dao.TUserMapper;
import com.yuanian.springbootProject.dao.TUserRoleMapper;
import com.yuanian.springbootProject.entity.TUser;
import com.yuanian.springbootProject.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService implements IUserService {

    @Resource
    private TUserMapper userMapper;

    @Resource
    private TUserRoleMapper userRoleMapper;

    @Override
    public int deleteByPrimaryKey(String userId) {
        return userMapper.deleteByPrimaryKey(userId);
    }

    @Override
    public int deleteUserAndRelationByPrimaryKey(String userId) {
        return userRoleMapper.deleteByUserId(userId) + userMapper.deleteByPrimaryKey(userId);
    }

    @Override
    public int insert(TUser record) {
        return userMapper.insert(record);
    }

    @Override
    public int insertSelective(TUser record) {
        return userMapper.insertSelective(record);
    }

    @Override
    public TUser selectByPrimaryKey(String userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public int updateByPrimaryKeySelective(TUser record) {
        return userMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TUser record) {
        return userMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<TUser> selectAll() {
        return userMapper.selectAll();
    }
}
